function backHome(form,actionUrl){
	form.action=actionUrl;
	form.submit();
	return true;
}

/**
  * Select checkbox to determine the number of
  */
function checkbox()
{
	var num=0; 
	if(document.formpage.custs.length==null)
	{
		document.formpage.custs.checked=true;
		num++;
	}else{
		var box = document.formpage.custs
		for(var i=0; i < box.length; i++) 
		{ 
			if(box[i].type=="checkbox") 
			{ 
				if(box[i].checked==true)
				{ 
					num++; 
				} 
			} 
		} 
	}
	return num;
}

/**
  * Select checkbox to determine the number of
  */
function checkbox2(field)
{
	var num=0; 
	var obj = document.getElementsByName(field);
	for(var i = 0;i < obj.length;i++){
		if(obj[i].checked)
			num++;
	}
	return num;
}
 /**
  * return checkbox's value if it checked
  * use  ',' jion
  */
  function checkboxvalue(field){
  	   var strvalues = "";
  	   var obj = document.getElementsByName(field);
   for(var i = 0;i < obj.length;i++){
   	  if(obj[i].type=="checkbox") { 
			if(obj[i].checked){
				if(strvalues==""){
					strvalues =obj[i].value; 
				}else{
					strvalues = strvalues+","+obj[i].value;
				}
			}
   	  }
	}
	return strvalues;
  }

function changeAllChecks(obj,field){
	var f = $ds(field);
	for (var i = 0; i < f.length; i++)
	{
		f[i].checked = obj.checked;
	}
}

function clearData(){
	for (var i = 0;i < arguments.length ; i++)
	{
		$d(arguments[i]).value = "";
	}
}

/**
     *  Select All checkbox
     */
function selectAll(obj)
{
	var tableObj=obj.offsetParent.offsetParent;
	for(var i = 1;i<tableObj.rows.length;i++)
	{
		try
		{
			var checkboxObj=tableObj.rows[i].cells[0].getElementsByTagName("input")[0];
			if(checkboxObj.type == "checkbox" && checkboxObj.checked != obj.checked)
				checkboxObj.click();
		}
		catch(e)
		{}
	}
}
	
 /**
  * Select checkbox to determine the number of
  */
	function checkboxnum(chxname)
	{
		var num=0; 
        var tempArrey = document.getElementsByName(chxname);
        for(var i=0;i<tempArrey.length;i++){
             if(tempArrey[i].checked){
                num++;
             }
        }
		return num;
	}

function $d(element) {
  if (arguments.length > 1) {
    for (var i = 0, elements = [], length = arguments.length; i < length; i++)
      elements.push($d(arguments[i]));
    return elements;
  }  
  element = document.getElementById(element);
  return element;
}
function $ds(element){
	 element = document.getElementsByName(element);
	 return element;
}

function formatDate(date){
	var d = new Date(date);
	var yyyy = d.getYear();
	var MM = formatDateNumber(d.getMonth());
	var dd = formatDateNumber(d.getDay());
	return yyyy + "-" + MM + "-" + dd;
}
function formatDateNumber(n){
	n = Number(n) < 10?"0"+n:n;
	return n;
}

/**
* beginDate > endDate
*/
function comparedt(beginDate,endDate){
	    var beginDate = new Date((beginDate).replace(/[-\.]/g,"/"));
	    var endDate = new Date((endDate).replace(/[-\.]/g,"/"));
	   if(beginDate>endDate){
		return true;	
	}
	return false;
}

 //document.oncontextmenu = function() {event.returnValue=false;} //rightkey 
 document.onkeydown  = function()
{	
	//alt + <--       alt + -->
	if((window.event.altKey)&&((window.event.keyCode==37)||(window.event.keyCode==39)))                       
	{         
		event.returnValue=false;
	}
	//back
	if((event.ctrlKey && event.keyCode==82))
	{  //ctrl + R      
	    event.keyCode=0;         
	    event.returnValue=false;         
	}         
}

function compareDate(beginDate,endDate){
   var beginDate = new Date((beginDate).replace(/[-\.]/g,"/"));
   var endDate = new Date((endDate).replace(/[-\.]/g,"/"));
   return beginDate - endDate;
}

// ----------------------------------------------------------------------------------------
// 限制栏位只能输入数字
function numberOnly(){
	return (event.keyCode > 47 && event.keyCode < 58 );
}

// ----------------------------------------------------------------------------------------

// 限制栏位只能输入数字与小数点

function numberDotOnly(){
	return (numberOnly() || event.keyCode == 46 );
}

//-----------------------------------------------判断利率--------------------
/**
 * 判断利率是否是0-1之间的数字
 */
 function checkisrate(obj,desc){
     var strrate = obj.value;
     if(strrate==""){
     	return true;
     }
 	if(isNaN(parseFloat(strrate))){
 		alert(desc+"请输入大于0小于1的浮点数字");
 		obj.value="";
 		obj.focus();
 		return false;
 	}
 	if(parseFloat(strrate)>1||parseFloat(strrate)<=0){
 		alert(desc+"请输入大于0小于1的浮点数字");
 		obj.value="";
 		obj.focus();
 		return false;
 	}
	var regu = "^[0-9]?[\.][0-9]{0,10}$"; 
	var re = new RegExp(regu); 
	if (re.test(strrate)) { 
		return true; 
	} else { 
		alert(desc+"请输入大于0小于1的浮点数字!");
		obj.value="";
 		obj.focus();
		return false; 
	} 
 	
 }

function initPageObj(){
	document.getElementById("pageObj.currentPage").value="1";
  	document.getElementById("pageObj.pageSize").value="10";
}

function getQueryStringArgs(){
	var qs=(location.search.length>0?location.search.substring(1):"");
	var args={};
	var items=qs.split("&");
	var item=null,name=null,value=null;
	
	for(var i=0;i < items.length ;i++){
		item= items[i].split("=");
		name= decodeURIComponent(item[0]);
		value=decodeURIComponent(item[1]);
		args[name]=value;
	}
	return args;
}